package Test.Exam;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @ClassName Main
 * @since: 2024/3/23 18:40
 * @auth: kirito
 * @description:
 **/
public class Main_1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] high = new int[n];
        for (int i = 0; i < n; i++) {
            high[i] = sc.nextInt();
        }
        boolean flag = false;
        for (int i = 1; i <= m; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            int h = sc.nextInt();
            for (int j = l-1; j <= r-1; j++) {
                high[j] -= h;
                if (high[j] <= 0) {
                    flag = true;
                }
            }
//            System.out.println(Arrays.toString(high));
            if (flag) {
                System.out.println(i);
                break;
            }
        }

    }
}
